$(function(){
    $('#form_announcement_new_locality, #form_user_new_locality, #locality, #form_locality, #form_servicepro_new_locality').after('<span id="iconLoading"></span>')
    
    var fnOnloading = function() {
        $('#iconLoading').html('<img style="padding-left:1em;" id="myIconLoading" src="'+IMAGE_URL+'iconLoading.gif" />');
    }
    
    var fnOnFinish = function () {
        $('#iconLoading').html('');
    }
    
    var a = $('#form_announcement_new_locality, #form_user_new_locality, #locality, #form_locality, #form_servicepro_new_locality').autocomplete({
        serviceUrl: AJAX_LOCALITY_URL,
        minChars: 3,
        width: 300,
        maxHeight:400,
        zIndex: 9999,
        delimiter: /(,|;)\s*/,
        onSelect: function(value, data){},
        onLoading: fnOnloading,
        onFinish: fnOnFinish,
        deferRequestBy: 0, //miliseconds
        params: {},
        noCache: false //set to true, to disable caching
    });
});
